sequential file

Using a sequential file, an application can allow users to store data into a text file for permanent storage. It also allows an application to read the data from the text file.

The data is written and read from a text file in a sequential order, and that is why it is called sequential file.

For example, you have a list of persons' names including PatTom, and Sue to write into a sequential file. VB .Net uses the StreamWriter class to carry out the operation.

 

  1. The StreamWriter of VB .Net will write Pat into the file, so Pat is the first record.
  2. Then the StreamWriter will write Tom into the file, so Tom will be the second record after Pat.
  3. Lastly, the StreamWriter will write Sue to the file, so Sue will be the third, Tom will stay at the second, and Sue will stay at the first.

 

The diagram below shows how the status of data change as the StreamWriter writes each name into the sequential file.

a

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

There are three basic operations in sequential files.

  1. Creating and Writing data into a file
  2. Appending or adding data into an existing file
  3. Reading data from an existing file

 

 

basic file handling by v. vanthana